var httpRequest;
function loading() {    //打开遮罩层	
	if ($("#overlay").length>0 && $("#ajaxbusyspinner").length>0) {
		$("#overlay").height($(document).height()).show();
    	$("#ajaxbusyspinner").show();
    } else {	//生成遮罩层	
    	var bheight=$(document).height();    	
        var bwidth=$("body").width();
        var overlay = $('<div id="overlay" style="background-color:black;display:none;z-index:10000;position:absolute;left:0px;top:0px;filter:Alpha(Opacity=30);-moz-opacity:0.4;opacity: 0.4;"></div>');
        overlay.css({width:bwidth, height:bheight, display:"block"}).appendTo($("body"));
        overlay.dblclick(abortRequest);
        $('<div id="ajaxbusyspinner" style="background-color:#FFFF99;position:fixed;left:0;bottom:0;_position:absolute;_top:expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight-this.offsetHeight-(parseInt(this.currentStyle.marginTop,10)||0)-(parseInt(this.currentStyle.marginBottom,10)||0)));display:block;height:32px;margin:0;padding:0;text-align:center;width:100%;z-index:10001;"><div style="width:45%;text-align:right;float:left;"><img style="border-width: 0px;" alt="Loading..." src="/images/ajax-loader_med.gif" /></div><div style="float:left;margin-top:5px;width:55%;text-align:left;line-height:100%; vertical-align: middle; font-size:200%;">&nbsp;Working...</div></div>').appendTo($("body"));
    }  
}
function closeLoading() {   //<{$lang.close}>遮罩层
	
	setTimeout(function(){		
		$("#overlay").hide();
		$("#ajaxbusyspinner").hide();	
	},300);
}
function abortRequest() {	//终止Ajax请求
	if (httpRequest!=undefined) {		
		httpRequest.abort();
		httpRequest = undefined;		
	}	
	closeLoading();
}
//块遮罩层
function partLoading(id) {		
	var partOverlay = $('<div id="partOverlay" style="background-color:black;z-index:10000;position:absolute;left:0px;top:0px;filter:Alpha(Opacity=20);-moz-opacity:0.2;opacity: 0.2;"></div>');
	partOverlay.css({'width':$('#'+id).width(), 'height':$('#'+id).height(), display:"block"});
	var imgOverlay = $('<div id="imgOverlay" style="z-index:10002;position:absolute;"><img src="/images/ajax-loader_med.gif" /></div>');
	imgOverlay.css({'top':Number($('#'+id).height())/2-5, 'left':Number($('#'+id).width())/2-5, display:"block"});	
	$('#'+id).append(partOverlay);
	$('#'+id).append(imgOverlay);
}
function closePartLoading(id) {
	setTimeout(function(){		
		$("#imgOverlay", "#"+id).remove();
		$("#partOverlay", "#"+id).remove();
	},300);
}


$(function(){
	if($.cookie("language")){
		$('#language').val($.cookie("language"));
	}
	//alert($.cookie("language"));
    $('#language').change(function(){
    	//$.cookie("language",$(this).val(), { expires: 7, path: "/", secure: true });
    	$('#lang_form').submit();
    	//window.location.href = window.location.href+'?lang='+$(this).val();
    });
	
});